<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    body {
        height: 3000px;
    }

    .box {
        position: fixed;
        right: 0;
        bottom: 50px;
        width: 200px;
        height: 50px;
        text-align: center;
        line-height: 50px;
        background-color: #ccc;
        display: none;
    }
</style>

<body>
    <div class="box">返回顶部</div>
    <script src="./js/jQuery.min.js"></script>
    <script>
        // window不可以加引号
        $(window).scroll(function () {
            // $(window).scrollTop()返回的是数字型Number，不带单位px
            if ($(this).scrollTop() >= 600) {
                $('.box').stop().fadeIn();
            } else {
                $('.box').stop().fadeOut();
            }

            console.log($(this).scrollTop());
        })
        $('.box').click(function () {
            $(window).scrollTop(0);
        })
    </script>
</body>

</html>